package com.ruoyi.circle.dao.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.circle.dao.ICircleBasicInfoDao;
import com.ruoyi.circle.domain.CircleBasicInfo;
import com.ruoyi.circle.mapper.CircleBasicInfoMapper;
import com.ruoyi.circle.mapper.CircleTagsRelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * 圈子基础信息Dao业务层处理
 *
 * @author 区嘉盛
 * @date 2025-06-09
 */
@Repository
public class CircleBasicInfoDaoImpl extends ServiceImpl<CircleBasicInfoMapper, CircleBasicInfo> implements ICircleBasicInfoDao {
    
    @Autowired
    private CircleBasicInfoMapper circleBasicInfoMapper;
    
    @Autowired
    private CircleTagsRelMapper circleTagsRelMapper;

    /**
     * 检查并删除没有标签关联的圈子
     * @param circleId 圈子ID
     */
    @Override
    public void checkAndDeleteCircleWithoutTags(Long circleId) {
        int tagCount = circleTagsRelMapper.checkCircleHasTags(circleId);
        if (tagCount == 0) {
            circleBasicInfoMapper.deleteCircleBasicInfoById(circleId);
        }
    }
}